package qualomelhor.server;

import java.io.IOException;
import java.util.HashMap;
import javax.servlet.http.*; 

public class LogoutServlet extends HttpServlet { 

	private static final long serialVersionUID = 0;

	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { 
        HttpSession session = req.getSession(true);
        session.setAttribute("UsuarioAtual", null);
        @SuppressWarnings("unchecked")
		HashMap<String, Object> mapSession = (HashMap<String, Object>)session.getAttribute("SESSIONVAR");
        if (mapSession == null) {
        	mapSession = new HashMap<String, Object>(0);
        }
        mapSession.put("USUARIOATUAL", null);
		session.setAttribute("SESSIONVAR", mapSession);
		session.setAttribute("USUARIOATUAL", null);
		resp.sendRedirect("/");
	}

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		doPost(req, resp);
	}
}